// 定义记分牌的类
class ScorePanel{
  // 分数
  score = 0;
  // 等级
  level = 1;

  scoreEle:HTMLElement;
  levelEle:HTMLElement;

  maxLevel:number;
  upScore:number;
  constructor(maxLevel:number = 10,upScore:number = 10){
    this.maxLevel = maxLevel;
    this.upScore = upScore;
    this.scoreEle = document.querySelector('#score')!;
    this.levelEle = document.querySelector('#level')!;
  }
  addScore(){
    this.scoreEle.innerHTML = ++this.score + '';
    if(this.score % this.upScore === 0){
      this.levelUp()
    }
  }
  levelUp(){
    if(this.level < this.maxLevel){
      this.levelEle.innerHTML = ++this.level + '';
    }
  }
  // 重置分数等级
  reScoreLevel(){
    this.score = 0;
    this.level = 1;
    this.scoreEle.innerHTML = 0 +'';
    this.levelEle.innerHTML = 1 +'';
  }
}

export default ScorePanel;